package com.iflytek.iot.redis.sharding.tools.config;


import com.iflytek.iot.redis.sharding.tools.constants.RedisModel;

import java.util.List;


/**
 * @author zurun
 * @date 2020/3/3 17:44:27
 */
public class ShardingProperty {
    private String name;
    private RedisModel model;
    private List<DataSource> dataSources;

    public static class DataSource {
        /**
         * 对于哨兵模式需要
         */
        private String master;
        private String nodes;
        private String password;
        private Short slotNo = 0;
        private Short weight = 0;
        private Pool pool;

        public String getMaster() {
            return master;
        }

        public DataSource setMaster(String master) {
            this.master = master;
            return this;
        }

        public String getNodes() {
            return nodes;
        }

        public DataSource setNodes(String nodes) {
            this.nodes = nodes;
            return this;
        }

        public String getPassword() {
            return password;
        }

        public DataSource setPassword(String password) {
            this.password = password;
            return this;
        }

        public Short getSlotNo() {
            return slotNo;
        }

        public DataSource setSlotNo(Short slotNo) {
            this.slotNo = slotNo;
            return this;
        }

        public Short getWeight() {
            return weight;
        }

        public DataSource setWeight(Short weight) {
            this.weight = weight;
            return this;
        }

        public Pool getPool() {
            return pool;
        }

        public DataSource setPool(Pool pool) {
            this.pool = pool;
            return this;
        }
    }

    public static class Pool {
        private Integer minIdle;
        private Integer maxIdle;
        private Integer maxTotal;
        private Long maxWaitMillis;

        public Integer getMinIdle() {
            return minIdle;
        }

        public Pool setMinIdle(Integer minIdle) {
            this.minIdle = minIdle;
            return this;
        }

        public Integer getMaxIdle() {
            return maxIdle;
        }

        public Pool setMaxIdle(Integer maxIdle) {
            this.maxIdle = maxIdle;
            return this;
        }

        public Integer getMaxTotal() {
            return maxTotal;
        }

        public Pool setMaxTotal(Integer maxTotal) {
            this.maxTotal = maxTotal;
            return this;
        }

        public Long getMaxWaitMillis() {
            return maxWaitMillis;
        }

        public Pool setMaxWaitMillis(Long maxWaitMillis) {
            this.maxWaitMillis = maxWaitMillis;
            return this;
        }
    }

    public String getName() {
        return name;
    }

    public ShardingProperty setName(String name) {
        this.name = name;
        return this;
    }

    public RedisModel getModel() {
        return model;
    }

    public ShardingProperty setModel(RedisModel model) {
        this.model = model;
        return this;
    }

    public List<DataSource> getDataSources() {
        return dataSources;
    }

    public ShardingProperty setDataSources(List<DataSource> dataSources) {
        this.dataSources = dataSources;
        return this;
    }
}
